<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <label class="el-form-item-label">id</label>
        <el-input v-model="query.id" clearable placeholder="id" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">月份</label>
        <el-input v-model="query.yearmonth" clearable placeholder="搜索格式：2021-06" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <label class="el-form-item-label">没设置则按照默认返利进行计算</label>
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="'设置返利点（为空则按照3%算）'" width="1000px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="170px">
          <el-row>
            <el-col :span="5">
          <el-form-item label="id" prop="id">
            <el-input v-model="form.id" style="width: 160px;" disabled />
          </el-form-item>
            </el-col>
            <el-col :span="5">
          <el-form-item label="月份">
            <el-input v-model="form.yearmonth" style="width: 370px;" disabled />
          </el-form-item>
            </el-col>
          </el-row>
          <el-row><el-col :span="6">
          <el-form-item label="1号">
            <el-input v-model="form.day1" style="width: 50px;" />
            <label>%</label>
          </el-form-item>
            </el-col><el-col :span="6">
          <el-form-item label="2号">
            <el-input v-model="form.day2" style="width: 50px;" />%
          </el-form-item>
            </el-col><el-col :span="6">
          <el-form-item label="3号">
            <el-input v-model="form.day3" style="width: 50px;" />%
          </el-form-item>
            </el-col></el-row>

          <el-row><el-col :span="6">
          <el-form-item label="4号">
            <el-input v-model="form.day4" style="width: 50px;" />%
          </el-form-item>
            </el-col><el-col :span="6">
          <el-form-item label="5号">
            <el-input v-model="form.day5" style="width: 50px;" />%
          </el-form-item>
            </el-col><el-col :span="6">
          <el-form-item label="6号">
            <el-input v-model="form.day6" style="width: 50px;" />%
          </el-form-item>
          </el-col></el-row>
          <el-row><el-col :span="6">
          <el-form-item label="7号">
            <el-input v-model="form.day7" style="width: 50px;" />%
          </el-form-item>
              </el-col><el-col :span="6">
          <el-form-item label="8号">
            <el-input v-model="form.day8" style="width: 50px;" />%
          </el-form-item>
              </el-col><el-col :span="6">
          <el-form-item label="9号">
            <el-input v-model="form.day9" style="width: 50px;" />%
          </el-form-item>
          </el-col></el-row>
          <el-row><el-col :span="6">
          <el-form-item label="10号">
            <el-input v-model="form.day10" style="width: 50px;" />%
          </el-form-item>
          </el-col><el-col :span="6">
          <el-form-item label="11号">
            <el-input v-model="form.day11" style="width: 50px;" />%
          </el-form-item>
          </el-col><el-col :span="6">
          <el-form-item label="12号">
            <el-input v-model="form.day12" style="width: 50px;" />%
          </el-form-item>
          </el-col></el-row>
          <el-row><el-col :span="6">
          <el-form-item label="13号">
            <el-input v-model="form.day13" style="width: 50px;" />%
          </el-form-item>
          </el-col><el-col :span="6">
          <el-form-item label="14号">
            <el-input v-model="form.day14" style="width: 50px;" />%
          </el-form-item>
          </el-col><el-col :span="6">
          <el-form-item label="15号">
            <el-input v-model="form.day15" style="width: 50px;" />%
          </el-form-item>
          </el-col></el-row>
          <el-row><el-col :span="6">
          <el-form-item label="16号">
            <el-input v-model="form.day16" style="width: 50px;" />%
          </el-form-item>
          </el-col><el-col :span="6">
          <el-form-item label="17号">
            <el-input v-model="form.day17" style="width: 50px;" />%
          </el-form-item>
          </el-col><el-col :span="6">
          <el-form-item label="18号">
            <el-input v-model="form.day18" style="width: 50px;" />%
          </el-form-item>
          </el-col></el-row>
          <el-row><el-col :span="6">
          <el-form-item label="19号">
            <el-input v-model="form.day19" style="width: 50px;" />%
          </el-form-item>
          </el-col><el-col :span="6">
          <el-form-item label="20号">
            <el-input v-model="form.day20" style="width: 50px;" />%
          </el-form-item>
          </el-col><el-col :span="6">
          <el-form-item label="21号">
            <el-input v-model="form.day21" style="width: 50px;" />%
          </el-form-item>
          </el-col></el-row>
          <el-row><el-col :span="6">
          <el-form-item label="22号">
            <el-input v-model="form.day22" style="width: 50px;" />%
          </el-form-item>
          </el-col><el-col :span="6">
          <el-form-item label="23号">
            <el-input v-model="form.day23" style="width: 50px;" />%
          </el-form-item>
          </el-col><el-col :span="6">
          <el-form-item label="24号">
            <el-input v-model="form.day24" style="width: 50px;" />%
          </el-form-item>
          </el-col></el-row>
          <el-row><el-col :span="6">
          <el-form-item label="25号">
            <el-input v-model="form.day25" style="width: 50px;" />%
          </el-form-item>
          </el-col><el-col :span="6">
          <el-form-item label="26号">
            <el-input v-model="form.day26" style="width: 50px;" />%
          </el-form-item>
          </el-col><el-col :span="6">
          <el-form-item label="27号">
            <el-input v-model="form.day27" style="width: 50px;" />%
          </el-form-item>
          </el-col></el-row>
          <el-row><el-col :span="6">
          <el-form-item label="28号">
            <el-input v-model="form.day28" style="width: 50px;" />%
          </el-form-item>
          </el-col><el-col :span="6">
          <el-form-item label="29号">
            <el-input v-model="form.day29" style="width: 50px;" />%
          </el-form-item>
          </el-col><el-col :span="6">
          <el-form-item label="30号">
            <el-input v-model="form.day30" style="width: 50px;" />%
          </el-form-item>
          </el-col></el-row>
          <el-row><el-col :span="6">
          <el-form-item label="31号">
            <el-input v-model="form.day31" style="width: 50px;" />%
          </el-form-item>
          </el-col></el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="id" label="id" />
        <el-table-column v-if="checkPer(['admin','monthRate:edit','monthRate:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
        <el-table-column prop="yearmonth" label="月份" />
        <el-table-column prop="day1" label="1号" />
        <el-table-column prop="day2" label="2号" />
        <el-table-column prop="day3" label="3号" />
        <el-table-column prop="day4" label="4号" />
        <el-table-column prop="day5" label="5号" />
        <el-table-column prop="day6" label="6号" />
        <el-table-column prop="day7" label="7号" />
        <el-table-column prop="day8" label="8号" />
        <el-table-column prop="day9" label="9号" />
        <el-table-column prop="day10" label="10号" />
        <el-table-column prop="day11" label="11号" />
        <el-table-column prop="day12" label="12号" />
        <el-table-column prop="day13" label="13号" />
        <el-table-column prop="day14" label="14号" />
        <el-table-column prop="day15" label="15号" />
        <el-table-column prop="day16" label="16号" />
        <el-table-column prop="day17" label="17号" />
        <el-table-column prop="day18" label="18号" />
        <el-table-column prop="day19" label="19号" />
        <el-table-column prop="day20" label="20号" />
        <el-table-column prop="day21" label="21号" />
        <el-table-column prop="day22" label="22号" />
        <el-table-column prop="day23" label="23号" />
        <el-table-column prop="day24" label="24号" />
        <el-table-column prop="day25" label="25号" />
        <el-table-column prop="day26" label="26号" />
        <el-table-column prop="day27" label="27号" />
        <el-table-column prop="day28" label="28号" />
        <el-table-column prop="day29" label="29号" />
        <el-table-column prop="day30" label="30号" />
        <el-table-column prop="day31" label="31号" />
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudMonthRate from '@/api/rate/monthRate'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { id: null, yearmonth: null, day1: null, day2: null, day3: null, day4: null, day5: null, day6: null, day7: null, day8: null, day9: null, day10: null, day11: null, day12: null, day13: null, day14: null, day15: null, day16: null, day17: null, day18: null, day19: null, day20: null, day21: null, day22: null, day23: null, day24: null, day25: null, day26: null, day27: null, day28: null, day29: null, day30: null, day31: null }
export default {
  name: 'MonthRate',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: 'monthrate', url: 'api/monthRate', idField: 'id', sort: 'id,desc', crudMethod: { ...crudMonthRate }})
  },
  data() {
    return {
      permission: {
        add: ['admin1', 'monthRate:add1'],
        edit: ['admin', 'monthRate:edit'],
        del: ['admin1', 'monthRate:del1']
      },
      rules: {
        id: [
          { required: true, message: 'id不能为空', trigger: 'blur' }
        ]
      },
      queryTypeOptions: [
        { key: 'id', display_name: 'id' },
        { key: 'yearmonth', display_name: '月份' }
      ]
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
